// 预设图案数据
export const patterns = {
  // 静物类
  stillLife: {
    block: {
      name: '方块',
      description: '最简单的静物图案',
      pattern: [
        [1, 1],
        [1, 1]
      ]
    },
    beehive: {
      name: '蜂巢',
      description: '六边形静物图案',
      pattern: [
        [0, 1, 1, 0],
        [1, 1, 0, 1],
        [0, 1, 1, 0]
      ]
    },
    loaf: {
      name: '面包',
      description: '面包形状的静物图案',
      pattern: [
        [0, 1, 1, 0],
        [1, 1, 0, 1],
        [0, 1, 0, 1],
        [0, 0, 1, 0]
      ]
    }
  },
  
  // 振荡器类
  oscillators: {
    blinker: {
      name: '闪烁器',
      description: '最简单的振荡器，周期为2',
      pattern: [
        [0, 1, 0],
        [0, 1, 0],
        [0, 1, 0]
      ]
    },
    toad: {
      name: '蟾蜍',
      description: '周期为2的振荡器',
      pattern: [
        [0, 0, 0, 0],
        [0, 1, 1, 1],
        [1, 1, 1, 0],
        [0, 0, 0, 0]
      ]
    },
    beacon: {
      name: '灯塔',
      description: '周期为2的振荡器',
      pattern: [
        [1, 1, 0, 0],
        [1, 1, 0, 0],
        [0, 0, 1, 1],
        [0, 0, 1, 1]
      ]
    }
  },
  
  // 滑翔机类
  gliders: {
    glider: {
      name: '滑翔机',
      description: '最基本的滑翔机，每4代移动一格',
      pattern: [
        [0, 1, 0],
        [0, 0, 1],
        [1, 1, 1]
      ]
    },
    lightweightSpaceship: {
      name: '轻型飞船',
      description: '每4代移动两格',
      pattern: [
        [0, 1, 1, 1, 1],
        [1, 0, 0, 0, 1],
        [0, 0, 0, 0, 1],
        [1, 0, 0, 1, 0]
      ]
    }
  }
}

// 获取所有图案
export function getAllPatterns() {
  const allPatterns = []
  for (const category in patterns) {
    for (const pattern in patterns[category]) {
      allPatterns.push({
        category,
        id: pattern,
        ...patterns[category][pattern]
      })
    }
  }
  return allPatterns
}

// 获取特定图案
export function getPattern(category, id) {
  return patterns[category]?.[id]
}

// 获取特定类别的所有图案
export function getPatternsByCategory(category) {
  return Object.entries(patterns[category] || {}).map(([id, pattern]) => ({
    category,
    id,
    ...pattern
  }))
}